# -*- coding: utf-8 -*-
# @Time    : 2016/04/12

from mathsolver.functions.base.base import BaseFunction, new_latex
from mathsolver.functions.base.objects import BaseValue
from mathsolver.functions.hanshu.jiou_qiujiexishi import JiOuJieXiShi


class JiOuQiuZhi(BaseFunction):
    """函数奇偶性求值"""
    def solver(self, *args):
        args_0, funcname = args[:-1], args[-1]

        # 奇偶性求解析式
        jiexishi_solver = JiOuJieXiShi().solver(*args_0)
        self.steps.extend(jiexishi_solver.steps)
        piecefunc = jiexishi_solver.output[0]

        result = piecefunc.run(funcname.var)
        self.steps.append(["", "代入解析式得 %s = %s" % (funcname.printing(), new_latex(result))])

        self.output.append(BaseValue(result))
        self.label.add("函数奇偶性求值")
        return self


if __name__ == '__main__':
    pass
